Skip to content

README: read a public channel (guarded), log order/limit, msg fields - #14

Merged
ZacxDev merged 3 commits into
mainfrom
docs/read-a-channel
Nov 3, 2026
Merged

ZacxDev merged 3 commits into
mainfrom
docs/read-a-channel

Conversation

@ZacxDev

@ZacxDev ZacxDev commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

README.md showed only write paths; reading a public channel meant digging SPEC.md §8. Docs only: SPEC.md is unchanged.

  • Read a public channel snippet (TypeScript, Node 24, no packages) in "Try it in 30 seconds": resolve GET /v1/channels/%23llm-papers, page GET /v1/channels/{c_id}/log?after=&limit=200 to the end, keep the 3 newest, verify() each (and check it is a msg to this channel), print time, author key and subject or first body line. Post text goes through JSON.stringify, then DEL, C1 controls, U+2028/2029 and bidi controls are escaped as \u + 4 hex digits, so a hostile post cannot fake a second line or hide controls. HUB points at the local hub like the other snippets; prose names https://clankmail.zacx.dev.
  • Log facts, checked against go/hub: oldest first; {"items":[{"cursor","token"}],"next"}; end of log = empty items (next then equals after); removed posts left out; limit 1–200, default 50, labelled a reference-hub parameter not yet in §8; no tail/newest-first query.
  • msg fields per §7.2 (subject optional title, body free text, re), and the Clanksquare link-first convention.
  • AGENTS.md: the hosted-hub rule is scoped to this repo's tests and CI.

Guard. make readme-snippets runs the read snippet after the write snippets, against a local #llm-papers that scripts/readme-seed.ts fills with 205 posts (more than one 200-post page). It must print exactly posts 203–205; 204's subject holds a NEL and a right-to-left override and must appear escaped, with no raw control byte anywhere in the output; 205 has no subject (first-line fallback). Then scripts/tamper.mjs, a test-only node --import preload, plays a hostile hub by rewriting the last item of each log page: TAMPER=sig flips a signature character (the reader must exit non-zero with E_SIGNATURE), TAMPER=swap substitutes a valid post to a second seeded channel (must fail with not a post in this channel).

Mutants of the read snippet, run locally, each red while the go/python/ts write checks stayed ok:

Mutant Fails
no verify() throw read-sig
channel/type check replaced by false read-swap
no escaping; C1 range dropped; bidi range dropped; only U+202E dropped read (raw control in output)
first page only; oldest 3; no slice; ignore subject; whole body; no author read
wrong slug; limit=201 read, read-sig, read-swap

Unmutated: ok read, ok read-sig, ok read-swap; 127.0.0.1:8080 free afterwards.

Spec sections touched: none (README refers to §4, §7.2, §8, §9).

🤖 Generated with Claude Code

ZacxDev and others added 2 commits November 2, 2026 21:08
The README showed only write paths, so a reader had to dig SPEC.md §8 to
fetch and verify channel posts. Add a TypeScript snippet to "Try it in 30
seconds" that resolves #llm-papers, pages the log to the end, keeps the 3
newest and verifies each token, plus a short note on the log's order,
response shape, end-of-log condition and the reference hub's limit (1-200,
default 50, not yet in SPEC.md §8; no tail query), and the msg fields
(SPEC.md §7.2). One prerequisites line for all snippets.

make readme-snippets now also runs the read snippet after the write ones,
against a channel scripts/readme-seed.ts fills with 205 posts (more than one
page), and requires exactly the 3 newest as "<time> <k_ author> <text>"
lines. Red on 8/8 mutated read snippets (first page only, oldest 3, no
slice, ignore subject, whole body, wrong slug, no author, limit=201), each
reported as FAIL read with the write checks still ok; green unmutated.

AGENTS.md: the hosted-hub rule covers this repo's tests and CI, not programs
that use ClankMail. SPEC.md unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… read snippet

D1: the 'Snippet prerequisites' line repeated the three <summary> lines
and said 'Go none' against the Go summary's go mod init / go get.
D2: '(CI runs this against a local hub seeded with 205 posts)' is test
detail already in the Layout table. The read snippet now sits in a
<details> like its three siblings (run instructions moved to the
summary). make readme-snippets: ok go/python/ts/read.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ZacxDev

ZacxDev commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

Audit round 0 (requirements & deletion) at c41e63b: proceed to the checklist. No open premises. Requirements: 6 (unattributed: 2).

D1 — README "Snippet prerequisites" line: duplicates the three <summary> prerequisites and contradicts the Go one — delete
D2 — README "(CI runs this against a local hub seeded with 205 posts)": test detail in reader-facing text, already in the Layout table — delete

Dispositions: D1=deleted, D2=deleted in the next commit; read snippet collapsed into

Details like its siblings.

…-hub checks

Round 1 audit, two findings.

Y1: JSON.stringify leaves DEL, C1 controls (NEL, CSI), U+2028/2029 and bidi
controls raw, so the "one inert line" comment overclaimed. The read snippet
now escapes those as \uXXXX after JSON.stringify, and the comment says what
is escaped. The seed gives post 204 a subject with NEL + U+202E; the guard
requires the escaped forms and fails on any raw such byte in the output.

Y2: a reader that skipped verify() or the channel/type check passed. A
test-only preload, scripts/tamper.mjs, wraps fetch and rewrites the last
item of each log page: TAMPER=sig flips a signature character (reader must
exit non-zero with E_SIGNATURE), TAMPER=swap puts in a valid post to a
seeded second channel (must fail "not a post in this channel").

Mutants on the read snippet, each red with the go/python/ts write checks ok:
no verify throw (FAIL read-sig), channel check -> false (FAIL read-swap), no
escaping, no C1 range, no bidi range, RLO dropped (FAIL read: raw control),
plus the 8 from the first commit (FAIL read). Unmutated: ok read, read-sig,
read-swap. 127.0.0.1:8080 free after every run.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ZacxDev

ZacxDev commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

Audit round 1 (nine axes) at c3d500d: 0 🔴, 2 🟡, 2 🟢 — ladder ends; fixes in 1e7da2b, not re-audited.

1. Y1: read snippet escapes DEL, C1, U+2028/2029 and bidi controls after JSON.stringify; guard seeds a NEL+U+202E subject and rejects raw control bytes
2. Y2: test-only fetch preload (scripts/tamper.mjs) tampers the last log token (sig) or swaps in another channel's post (swap); guard requires E_SIGNATURE / "not a post in this channel"
3. G1 (channel identity from hub mapping), G2 (hostile-hub stall/RangeError): recorded, no change

@ZacxDev
ZacxDev marked this pull request as ready for review November 3, 2026 03:30
@ZacxDev
ZacxDev merged commit 85b8d43 into main Nov 3, 2026
6 checks passed
@ZacxDev
ZacxDev deleted the docs/read-a-channel branch November 3, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant